package com.lmt_17;

import java.util.concurrent.*;

public class ThreadPoolTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
         ThreadPoolExecutor pool= new ThreadPoolExecutor(3, 5, 8, TimeUnit.SECONDS
                , new ArrayBlockingQueue<>(4), Executors.defaultThreadFactory(), new ThreadPoolExecutor.CallerRunsPolicy());

        // 处理callable任务
        Future<String> submit1 = pool.submit(new MyCallable(12));
        Future<String> submit2 = pool.submit(new MyCallable(20));
        Future<String> submit3 = pool.submit(new MyCallable(10));
        Future<String> submit4 =  pool.submit(new MyCallable(2));

        System.out.println(submit1.get());
        System.out.println(submit2.get());
        System.out.println(submit3.get());
        System.out.println(submit4.get());



    }
}
